# Name: Main.py #
# 
# Author: Waters #
# Creation Date: 2021.11.17 #
# Version: v0.1.1 #
# 

import os
import datetime
import tkinter as TK
import threading

import GUI
import GlobalVariables

class ReBuildCommand(GUI.MainWindow):
	"""docstring for ReBuildCommand"""
	def __init__(self, g_obMainWindow):
		super(ReBuildCommand, self).__init__(g_obMainWindow)
		g_obMainWindow.title('%s_%s' %(g_szSoftwareName, g_szVersionNum))

	def StartProcess(self):
		# Check input dir
		temp_szInputDir = self.g_obEntInputDir.get()
		temp_szOutputDir = self.g_obEntOutputDir.get()
		if(temp_szInputDir and temp_szOutputDir):
			pass
		else:
			self.g_obSTError.insert('end', '“源文件路径”与“输出路径”均不能为空。\n')
			self.g_obSTError.see('end')
			return 0
		# Create process thread
		thdStartStandProc = threading.Thread(target = StantardProcess, args = (temp_szInputDir, temp_szOutputDir, ))
		thdStartStandProc.start()

def CreateGlobalVarialbe():
	globals().update(GlobalVariables.GetAllCustomGlobalVariables())
	global g_szVersionNum
	g_szVersionNum = 'v0.1.1'
	return 0

def CreateGUI():
	global g_obMainWindow
	root = TK.Tk()
	g_obMainWindow = ReBuildCommand(root)
	return root

def StantardProcess(szInputDir, szOutputDir):
	g_obMainWindow.g_obSTRunState.insert('end', '开始运行：\n输入路径：%s\n输出路径：%s\n' %(szInputDir, szOutputDir))
	g_obMainWindow.g_obSTRunState.see('end')
	g_obMainWindow.g_obSTError.insert('end', '错误信息：\n')
	g_obMainWindow.g_obSTError.see('end')
	return 0

if __name__ == '__main__':
	CreateGlobalVarialbe()
	CreateGUI().mainloop()